package com.example.demo.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.example.demo.custom.BaseRepository;
import com.example.demo.entity.Insurance;
import com.example.demo.entity.Insurance2;
@Repository
public interface Insurance2Repository extends BaseRepository<Insurance2, Integer>{

	List<Insurance2> findByInsuranceId(Integer id);

	List<Insurance2> findByInsurance(Insurance ins);

	/**
	 * @param car
	 * @return 通过时间排序得到最新一条
	 */
	@Query(value = "SELECT  *  FROM insurance2 t WHERE t.insurance_id=? ORDER BY t.begin_date DESC LIMIT 1 ",nativeQuery=true)
	Insurance2 findByInsurance2(Integer id);

}
